package myicesscheduler.web;

import static org.junit.Assert.*;

import java.io.File;
import java.util.List;

import org.junit.BeforeClass;
import org.junit.Test;

public class AdminMenuControllerTest
{
   @BeforeClass
   static public void beforeClass()
   {
      final String delim = String.valueOf( File.separatorChar );

      System.setProperty( MyFolderUtil.uploadFolder_folderPropertyName, "." + delim + "WebContent"
            + delim + "WEB-INF" + delim + "upload" );

      System.setProperty( MyFolderUtil.backupFolder_folderPropertyName, "." + delim + "WebContent"
            + delim + "WEB-INF" + delim + "backup" );
   }

   @Test
   public void getBackupFilesInfo()
   {
      final String[] zipFiles = AdminBackupCompressController.compress();
      final List< MyFileInfo > files = AdminMenuController.getBackupFilesInfo();

      assertTrue( zipFiles.length >= 2 );
      assertTrue( zipFiles.length < files.size() );

      for( final MyFileInfo info : files )
      {
         assertEquals( "backup", info.getDir() );
         assertTrue( info.getFilename().toLowerCase().endsWith( ".zip" ) );
      }
   }
}
